<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Document</title>
  </head>
  <body>
    <script>
      Array.prototype.sum = function () {
        var sum = 0;
        for (var i = 0; i < this.length; i++) {
          sum += this[i];
        }
        return sum;
      };
      var arr = [1, 2, 3];
      console.log(arr.sum());		// 输出结果：6
    </script>
  </body>
</html>